package com.hand.hap.demo.service.impl;

import com.hand.hap.core.IRequest;
import com.hand.hap.system.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hand.hap.demo.dto.DemoBankBranch;
import com.hand.hap.demo.service.IDemoBankBranchService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service

public class DemoBankBranchServiceImpl extends BaseServiceImpl<DemoBankBranch> implements IDemoBankBranchService{

    @Autowired
    private IDemoBankBranchService demoBankBranchService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<DemoBankBranch> myBatchSubmit(IRequest request, List<DemoBankBranch> list) {
       if (list!=null&&!list.isEmpty()){
           for (int i = 0;i<list.size();i++){
               DemoBankBranch demoBankBranch = list.get(i);
              Long bankBranchId =  demoBankBranch.getBankBranchId();
              if (bankBranchId==null){
//insert
                  demoBankBranchService.insertSelective(request,demoBankBranch);
              }else{
//                  update
                  demoBankBranchService.updateByPrimaryKeySelective(request,demoBankBranch);
              }
           }
       }

       return list;
    }
}